package hms.payment;

import java.sql.*;

import hms.database.*;

/*Using the DBRowObject class, this class passes data from
 * the HMS database to the Check payment option
 * 
 * @author Edgar Onukwugha*/

public class CheckOption extends DBRowObject implements MoneyOption {

	private int payment_method_ID;
	private String account_number, routing_number, bank_name;
	private double check_amount;
	
	public CheckOption(){
		super();
		payment_method_ID = -1;
		account_number = "xxxxxxxxx";
		routing_number = "xxxxxxxxx";
		bank_name = "NONE";
		check_amount = 0;
	}
	
	public CheckOption(int payment_ID){
		super(payment_ID);
	}
	
	/////////////////////////////////////////////////
	/////               SETTERS                //////
	/////////////////////////////////////////////////
		
	public void setPaymentMethodID(int i){
		payment_method_ID = i;
		markAsChanged();
	}
	
	public void setAccountNumber(String i){
		account_number = i;
		markAsChanged();
	}
	
	public void setRoutingNumber(String i){
		routing_number = i;
		markAsChanged();
	}
	
	public void setBankName(String i){
		bank_name = i;
		markAsChanged();
	}

	public void setCheckAmount(double i){
		check_amount = i;
		markAsChanged();
	}
	
	/////////////////////////////////////////////////
	/////               GETTERS                //////
	/////////////////////////////////////////////////
	
	public int getPayemntMethodID(){
		return payment_method_ID;
	}
	
	public String getAccountNumber(){
		return account_number;
	}
	
	public String getRoutingNumber(){
		return routing_number;
	}
	
	public String getBankName(){
		return bank_name;
	}
	
	public double getCheckAmount() {
		return check_amount;
	}
	
	@Override
	protected String[] getFieldNames() {
		String[] output = {
		"PAYMENT_METHOD_ID",
		"ACCOUNT_NUMBER",
		"ROUTING_NUMBER",
		"BANK_NAME",
		"CHECK_AMOUNT"};
		
		return output;
	}

	@Override
	protected void loadPreparedStatement(PreparedStatement stmt)
			throws SQLException {
		stmt.setInt(1, payment_method_ID);
		stmt.setString(2, account_number);
		stmt.setString(3, routing_number);
		stmt.setString(4, bank_name);
		stmt.setDouble(5, check_amount);
		
		// TODO Auto-generated method stub		
	}

	@Override
	protected String getUniqueIdentifierFieldName() {
		// TODO Auto-generated method stub
		return "PAYMENT_ID";
	}

	@Override
	protected String getTableName() {
		// TODO Auto-generated method stub
		return "CHECK_ACCOUNT";
	}

	@Override
	protected void loadFromDatabase(ResultSet rs) throws SQLException {
		this.payment_method_ID = rs.getInt("PAYMENT_METHOD_ID");
		this.account_number = rs.getString("ACCOUNT_NUMBER");
		this.routing_number = rs.getString("ROUTING_NUMBER");
		this.bank_name = rs.getString("BANK_NAME");
		this.check_amount = rs.getDouble("CHECK_AMOUNT");
	}

	@Override
	protected boolean allowDuplicateRows() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public double getAmount() {
		return check_amount;
	}

}
